using System;
using System.Collections.Generic;
using System.Linq;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Audio;
using Microsoft.Xna.Framework.Content;
using Microsoft.Xna.Framework.GamerServices;
using Microsoft.Xna.Framework.Graphics;
using Microsoft.Xna.Framework.Input;
using Microsoft.Xna.Framework.Input.Touch;
using Microsoft.Xna.Framework.Media;

namespace MemoryGame
{
    public class StateLogo : DEF
    {
        public static Texture2D logoBitmap = null;

        public static long timer = 0;
        public static int loadingStep = 0;
        public static String sizePreFix = "";
        public static void SendMessage(int type)
        {

            switch (type)
            {
                case MESSAGE_CTOR:

                    logoBitmap = Game1.contentManager.Load<Texture2D>("SplashScreenImage");
                    Game1.mLevelUnlock = Game1.instanceGame1.lockUnlock();
                    for (int i = 0; i < texttureButtonMenu.Length; i++)
                    {
                        if (texttureButtonMenu[i] == null)
                        {
                            texttureButtonMenu[i] = Game1.contentManager.Load<Texture2D>("image//menu//" + DEF.textureString[i]);
                        }


                    }
                    Game1.instanceGame1.CheckMusicPlaying();
                    break;
                case MESSAGE_UPDATE:
                    if (StateGameplay.backgroundImage == null)
                        StateGameplay.backgroundImage = Game1.contentManager.Load<Texture2D>("image//screen//screen1");                   
                    //load 6 bubble
                  
                    if (Dialog.isShowDialog)
                    {
                        if (InputState.isBackKeyPress())
                            Game1.instanceGame1.Exit();

                        Dialog.updateDialog();
                        return;
                    }
                    if (SoundManager.playerEffect == null)
                    {
                        SoundManager.initSounds();
                    }

                    if (GamePad.GetState(PlayerIndex.One).Buttons.Back == ButtonState.Pressed)
                    {
                        //Game1.instanceGame1.Exit(); 
                    }

                    if (Game1.timeCurrent - Game1.timeBeginCurrentState > 3000)
                    {
                        Game1.changeState(Game1.STATE_MAINMENU);
                    }

                    DEF.BUTTON_CANCEL_CONFIRM_W = (int)(texttureButtonMenu[DEF.FRAME_CANCEL_NORMAL].Width * Game1.SCALE_X);
                    DEF.BUTTON_CANCEL_CONFIRM_H = (int)(texttureButtonMenu[DEF.FRAME_CANCEL_NORMAL].Height * Game1.SCALE_Y);
                    DEF.DIALOG_BUTTON_CONFIRM_W = DEF.BUTTON_CANCEL_CONFIRM_W;
                    DEF.DIALOG_BUTTON_CONFIRM_H = DEF.BUTTON_CANCEL_CONFIRM_H;

                    break;
                case MESSAGE_PAINT:

                    if (Dialog.isShowDialog)
                    {
                        Dialog.drawDialog(Game1.spriteBatch);
                        if (Game1.timeCurrent % 1000 < 500)
                        {
                            string dialogText = "Touch Screen To Continue";
                            Vector2 tempMeasure = Game1.fontNormal.MeasureString(dialogText);
                            Game1.spriteBatch.DrawString(Game1.fontNormal, dialogText, new Vector2((DEF.SCREEN_WIDTH - (int)tempMeasure.X) / 2, DEF.SCREEN_HEIGHT  - (int)tempMeasure.Y - 10), Color.White);
                        }
                        return;
                    }
                    int x = (int)(SCREEN_WIDTH - logoBitmap.Width * Game1.SCALE_X) / 2;
                    int y = (int)(SCREEN_HEIGHT - logoBitmap.Height * Game1.SCALE_Y) / 2;
                    Game1.spriteBatch.Draw(logoBitmap, new Vector2(x, y), null, Color.White, 0f, new Vector2(0, 0), new Vector2(Game1.SCALE_X, Game1.SCALE_Y), SpriteEffects.None, 1);

                    //   Game1.spriteBatch.Draw(logoBitmap, new Vector2(0, 0),, Color.White);

                    break;
                case MESSAGE_DTOR:
                    break;
            }
        }
    }
}
